package com.csdj.springboottest.util;

import java.util.Random;
import java.util.UUID;

public class RandomUtil {

    private final static String CHARATS = "0123456789abcdefg.....xyzABCD...XYZ";
    private final static String NUMBERS = "0123456789";
    private final static String LETTER = "abcdefg.....xyz";
    private final static String UPPER = "abcdefg.....xyz";

    public static String getToken(){
        return UUID.randomUUID().toString().replaceAll("-","");
    }

    public static String genRandChar(int len,String chars){
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        while (len >0){
            sb.append(chars.charAt(random.nextInt(chars.length())));
            len --;
        }
        return sb.toString();
    }

    public static String genRandNumber(int len){
        return genRandChar(len,NUMBERS);
    }
}
